home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Atari Mega Archive 1
/
Atari Mega Archive - Volume 1.iso
/
language
/
iconv8_s.arc
/
ICONT.ARC
/
ERR.C
< prev
next >
Wrap
C/C++ Source or Header
|
1990-03-28
|
8KB
|
262 lines
/*
* err.c -- routines for producing error messages.
*/
#include "..\h\config.h"
#include "general.h"
#include "token.h"
#include "tlex.h"
#include "trans.h"
#include "tree.h"
#include "tproto.h"
/*
* Prototype.
*/
hidden char *mapterm Params((int typ,struct node *val));
extern int tfatals;
static struct errmsg {
int e_state; /* parser state number */
char *e_mesg; /* message text */
} errtab[] = {
/*
* Initialization of table that maps error states to messages.
*/
1, "end of file expected",
2, "global, record, or procedure declaration expected",
11, "missing semicolon",
13, "link list expected",
15, "global, record, or procedure declaration expected",
16, "missing record name",
19, "invalid global declaration",
24, "missing procedure name",
26, "missing field list in record declaration",
28, "missing end",
29, "missing semicolon or operator",
44, "invalid argument for unary operator",
45, "invalid argument for unary operator",
46, "invalid argument for unary operator",
47, "invalid argument for unary operator",
48, "invalid argument for unary operator",
49, "invalid argument for unary operator",
50, "invalid argument for unary operator",
51, "invalid argument for unary operator",
52, "invalid argument for unary operator",
53, "invalid argument for unary operator",
54, "invalid argument for unary operator",
55, "invalid argument for unary operator",
56, "invalid argument for unary operator",
57, "invalid argument for unary operator",
58, "invalid argument for unary operator",
59, "invalid argument for unary operator",
60, "invalid argument for unary operator",
61, "invalid argument for unary operator",
62, "invalid argument for unary operator",
63, "invalid argument for unary operator",
64, "invalid argument for unary operator",
65, "invalid argument for unary operator",
66, "invalid argument for unary operator",
67, "invalid argument for unary operator",
77, "invalid create expression",
84, "invalid keyword construction",
92, "invalid if control expression",
93, "invalid case control expression",
94, "invalid while control expression",
95, "invalid until control expression",
96, "invalid every control expression",
97, "invalid repeat expression",
100, "missing link file name",
101, "missing parameter list in procedure declaration",
104, "invalid local declaration",
105, "invalid initial expression",
110, "invalid argument",
111, "invalid argument",
112, "invalid argument in assignment",
113, "invalid argument in assignment",
114, "invalid argument in assignment",
115, "invalid argument in assignment",
116, "invalid argument in augmented assignment",
117, "invalid argument in augmented assignment",
118, "invalid argument in augmented assignment",
119, "invalid argument in augmented assignment",
120, "invalid argument in augmented assignment",
121, "invalid argument in augmented assignment",
122, "invalid argument in augmented assignment",
123, "invalid argument in augmented assignment",
124, "invalid argument in augmented assignment",
125, "invalid argument in augmented assignment",
126, "invalid argument in augmented assignment",
127, "invalid argument in augmented assignment",
128, "invalid argument in augmented assignment",
129, "invalid argument in augmented assignment",
130, "invalid argument in augmented assignment",
131, "invalid argument in augmented assignment",
132, "invalid argument in augmented assignment",
133, "invalid argument in augmented assignment",
134, "invalid argument in augmented assignment",
135, "invalid argument in augmented assignment",
136, "invalid argument in augmented assignment",
137, "invalid argument in augmented assignment",
138, "invalid argument in augmented assignment",
139, "invalid argument in augmented assignment",
140, "invalid argument in augmented assignment",
141, "invalid argument in augmented assignment",
142, "invalid argument in augmented assignment",
143, "invalid argument in augmented assignment",
144, "invalid to clause",
145, "invalid argument in alternation",
146, "invalid argument",
147, "invalid argument",
148, "invalid argument",
149, "invalid argument",
150, "invalid argument",
151, "invalid argument",
152, "invalid argument",
153, "invalid argument",
154, "invalid argument",
155, "invalid argument",
156, "invalid argument",
157, "invalid argument",
158, "invalid argument",
159, "invalid argument",
160, "invalid argument",
161, "invalid argument",
162, "invalid argument",
163, "invalid argument",
164, "invalid argument",
165, "invalid argument",
166, "invalid argument",
167, "invalid argument",
168, "invalid argument",
169, "invalid argument",
170, "invalid argument",
171, "invalid argument",
172, "invalid argument",
173, "invalid argument",
177, "invalid field name",
204, "missing right parenthesis",
206, "missing right brace",
208, "missing right bracket",
214, "missing then",
215, "missing of",
220, "missing identifier",
223, "missing right parenthesis",
225, "missing end",
226, "invalid declaration",
227, "missing semicolon or operator",
293, "missing right bracket",
296, "missing right brace",
298, "missing right parenthesis",
305, "invalid do clause",
306, "invalid then clause",
307, "missing left brace",
308, "invalid do clause",
309, "invalid do clause",
310, "invalid do clause",
312, "invalid argument list",
318, "invalid by clause",
320, "invalid section",
331, "invalid case clause",
336, "missing right bracket",
338, "missing right bracket or ampersand",
340, "invalid else clause",
341, "missing right brace or semicolon",
343, "missing colon",
344, "missing colon or ampersand",
349, "invalid case clause",
350, "invalid default clause",
351, "invalid case clause",
-1, "syntax error"
};
/*
* yyerror produces syntax error messages. tok is the offending token
* (yychar), lval is yylval, and state is the parser's state.
*
* errtab is searched for the state, if it is found, the associated
* message is produced; if the state isn't found, "syntax error"
* is produced.
*/
novalue yyerror(tok, lval, state)
int tok, state;
nodeptr lval;
{
register struct errmsg *p;
if (tok_loc.n_file)
fprintf(stderr, "File %s; ", tok_loc.n_file);
if (tok == EOFX) /* special case end of file */
fprintf(stderr, "unexpected end of file\n");
else {
fprintf(stderr, "Line %d # ", Line(lval));
if (Col(lval))
fprintf(stderr, "\"%s\": ", mapterm(tok,lval));
for (p = errtab; p->e_state != state && p->e_state >= 0; p++) ;
fprintf(stderr, "%s\n", p->e_mesg);
}
tfatals++;
nocode++;
}
/*
* tfatal produces the translator error messages s1 and s2 (if nonnull). The
* location of the error is found in tok_loc.
*/
novalue tfatal(s1, s2)
char *s1, *s2;
{
if (tok_loc.n_file)
fprintf(stderr, "File %s; ", tok_loc.n_file);
fprintf(stderr, "Line %d # ", tok_loc.n_line);
if (s2)
fprintf(stderr, "\"%s\": ", s2);
fprintf(stderr, "%s\n", s1);
tfatals++;
nocode++;
}
/*
* nfatal produces the error message s and associates it with source location
* of node.
*/
novalue nfatal(n, s)
nodeptr n;
char *s;
{
fprintf(stderr, "File %s; ", File(n));
fprintf(stderr, "Line %d # ", Line(n));
fprintf(stderr, "%s\n", s);
tfatals++;
nocode++;
}
/*
* mapterm finds a printable string for the given token type
* and value.
*/
static char *mapterm(typ,val)
int typ;
nodeptr val;
{
register struct toktab *t;
register int i;